package code;

/* action_:   1:pkt transmission   2: UDP generate    3:pkt dequeue
 * 4: routing update 5: TCP transmission
 * 
 * 
 * 
 * 
 */

public class Event {
	public int action_;
	double timer_; // time for the event

	int nexthopIP_;
	Packet pkt_;
	Node nexthop_;
	UDP udp_;

	public Event(int action_, double timer_, int nexthopIP_, Packet pkt_,
			Node nexthop_, UDP udp_) {
		super();
		this.action_ = action_;
		this.timer_ = timer_;
		this.nexthopIP_ = nexthopIP_;
		this.pkt_ = pkt_;
		this.nexthop_ = nexthop_;
		this.udp_ = udp_;
	}

	public Event() {
		this.timer_ = 0;
		this.action_ = 0;
		this.nexthopIP_ = 0;
	}

	void execute_() {
		switch (action_) {
		case 1:
			action1_();
			break;
		case 2:
			action2_();
			break;
		case 3:
			action3_();
			break;
		case 4:
			action4_();
			break;
		case 5:
			action5_();
			break;
		case 6:
			action6_();
			break;
		default:
			System.out.println("No such action");
		}
	}

	void action1_() {
		Node n = pkt_.m_nexthop_;
		// this.pkt_.m_link_.m_last_trans_time_=Global.TIME;
		n.get_pkt_(pkt_);
	}

	void action2_() {
		this.udp_.generate_traffic_();

	}

	void action3_() {
		pkt_.m_link_.dequeue(pkt_);
	}

	void action4_() {

	}

	void action5_() {

	}

	void action6_() {

	}

}
